﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;


namespace CSharp.Libs.Database
{
    class Program
    {
        static void Main(string[] args)
        {
            //string strFilename = string.Concat((new FileInfo(Assembly.GetExecutingAssembly().Location)).DirectoryName, @"\SQLiteHandler_Test.s3db");
            //SQLiteHandler slh = new SQLiteHandler(strFilename);
            ////SQLiteHandler slh = new SQLiteHandler(@"g:\test4564.s3db", ConnectionBehaviour.AutomaticOpenAndClose);
            //slh.Dispose();


            /****************************************
             * Example executing prepared statement *
             ****************************************/
            SQLiteHandler slh = new SQLiteHandler(@"g:\PicLib.s3db");

            ArrayList aryParams = new ArrayList();
            aryParams.Add(new SqlParameter() { Name = "@BasePathId", Type = System.Data.DbType.Int64, Value = "0" });
            aryParams.Add(new SqlParameter() { Name = "@FullFileName", Type = System.Data.DbType.String, Value = @"C:\Full\File\Name.txt" });
            aryParams.Add(new SqlParameter() { Name = "@FileName", Type = System.Data.DbType.String, Value = "Name.txt" });
            aryParams.Add(new SqlParameter() { Name = "@Path", Type = System.Data.DbType.String, Value = @"C:\Full\File" });
            aryParams.Add(new SqlParameter() { Name = "@Hash", Type = System.Data.DbType.String, Value = "lghiqf4ilwgaldsifghaKGSYK" });
            int intAffectedRows = slh.ExecutePreparedStatement(@"INSERT INTO tblPictureObjects (BasePathId, FullFileName, FileName, Path, Hash) VALUES (@BasePathId, @FullFileName, @FileName, @Path, @Hash)", aryParams);

            slh.Dispose();
            slh = null;

            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
    }
}
